package com.ylfstu.jdbc.datasource;

import com.ylfstu.jdbc.JdbcUtils.JdbcUtils;
import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 * @Author: Joy_yang
 * @Date: 2022/10/20 13:59
 */
public class ConQuestion {

    //代码 连接mysql 5000次
    @Test
    public void testCon() {

        long start = System.currentTimeMillis();
        System.out.println("开始连接...");
        for (int i = 0; i < 5000; i++) {
            Connection connection = JdbcUtils.getConnection();
            //执行sql...

            JdbcUtils.close(null, null, connection);
        }
        long end = System.currentTimeMillis();
        System.out.println("传统方式接连5000次 耗时=" + (end - start));//传统方式接连5000次 耗时=12616
    }
}
